import { TableColumnProps } from "ant-design-vue";
import { ref } from "vue";
import { FinancialItem, InvoiceType, PayRecMethod } from "/@/api/main/financial/models";
import { filterColumns, getLabelByValueFromEnum, handleDateRowRender } from "/@/utils/common";

export function usePayment(exceptKeys?: string[]) {
  const columns: TableColumnProps<FinancialItem>[] = [
    {
      title: "操作类型",
      dataIndex: "opType",
      customRender({ text }) {
        return text === 0 ? "付款单" : "收款单";
      },
    },
    {
      title: "收付款单号",
      dataIndex: "orderNo",
    },
    {
      title: "关联结算单号",
      dataIndex: "settlementOrderNo",
    },
    {
      title: "供应商",
      dataIndex: "supplierName",
    },
    {
      title: "关联发票",
      dataIndex: "invoiceNum",
    },
    {
      title: "收付款日期",
      dataIndex: "payRecDate",
      customRender: handleDateRowRender,
    },
    {
      title: "收付款金额",
      dataIndex: "payRecAmount",
    },
    {
      title: "收付款方式",
      dataIndex: "payRecMethod",
      customRender({ text }) {
        return getLabelByValueFromEnum(text, PayRecMethod, "payRecMethod");
      },
    },
    {
      title: "收付款凭据编号",
      dataIndex: "voucherNum",
    },
    {
      title: "状态",
      dataIndex: "status",
    },
    {
      title: "操作",
      key: "oper",
      fixed: "right",
    },
  ];
  if (exceptKeys) {
    filterColumns(columns, exceptKeys);
  }
  return {
    columns,
  };
}
